package com.dingding.order.core.common.rule.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.common.core.base.daox.IBaseDaoX;
import com.dingding.common.core.base.daox.ISQLBaseDao;
import com.dingding.order.common.dto.rule.ResValuationRule;
import com.dingding.order.core.common.rule.dao.IValuationRuleDao;
import com.dingding.order.core.common.rule.sql.ValuationRuleSQL;

/**
 * 
 * @ClassName: ValuationRuleDaoImpl 
 * @Description: 计价规则业务逻辑实现类 
 * @author YHQ
 * @date 2016年12月7日 下午2:52:43
 * @since V2.5.7
 * 
 */
@Component("valuationRuleDao")
public class ValuationRuleDaoImpl implements IValuationRuleDao {

	@Resource(name = "baseDaoX")
	private IBaseDaoX baseDaoX;
	
	@Resource(name = "SQLBaseDao")
	private ISQLBaseDao sqlBaseDao;
	
	private Logger log = Logger.getLogger(this.getClass());
	
	/**
	 * 
	 * @Title: getChargeRuleList 
	 * @Description: 根据城市Id获取该城市的每个有效车型的计价规则 
	 * @param cityId 城市Id
	 * @author YHQ 
	 * @since V2.5.7
	 * @return List<ResValuationRule>    返回类型
	 * 
	 */
	@Override
	@Transactional(readOnly = true)
	public List<ResValuationRule> getChargeRuleList(String cityId) {
		
		try {
			return sqlBaseDao.listSqlToCustomBean(ResValuationRule.class, ValuationRuleSQL.GET_CHARGE_RULE_LIST, cityId);
		} catch (Exception e) {
			log.error("根据城市Id获取每个有效车型的计价规则 时出现异常   类：" + this.getClass() + " getChargeRuleList()", e);
		}
		
		return null;
	}

	/**
	 * 
	 * @Title: getChargeRuleByVehicleLevelId 
	 * @Description: 根据车辆Id获取车辆计价规则
	 * @param vehicleLevelId 车辆等级Id
	 * @author YHQ 
	 * @since V2.5.7
	 * @return ResValuationRule    返回类型
	 * 
	 */
	@Override
	@Transactional(readOnly = true)
	public ResValuationRule getChargeRuleByVehicleLevelId(Integer vehicleLevelId) {
		
		try {
			return sqlBaseDao.sqlToCustomBeanUnique(ResValuationRule.class, ValuationRuleSQL.GET_CHARGE_RULE_BY_VEHICLE_ID, vehicleLevelId);
		} catch (Exception e) {
			log.error("根据城市Id获取每个有效车型的计价规则 时出现异常   类：" + this.getClass() + " getChargeRuleList()", e);
		}
		
		return null;
	}

}
